<template>
	<view class="content bg-#F6F9F8  photo-white">

		<custom_navbar :title="navbar_title" @getNavHeight="getNavHeight" theme="white" />
		
		<view class="news_list">
			<view class="news_list_one"  v-for="(item,index) in newsList" v-if="newsList.length != 0"
			@click="this.navigateTo(`/pagesA/news/detail?id=`+item.id);"
			>
				<view class="news_list_one_1">{{item.title}}</view>
				<view class="news_list_one_2">{{item.create_time}}  </view>
			</view>
			
			<view v-else class="list-nodata">暂无数据</view>
		</view>
		
	</view>

</template>

<script>
	import {
		navigateTo,
		navigateBack
	} from "@/hooks";
	import custom_navbar from "./components/photo.vue";
	import {
		noticeList
	} from '@/api/home';
	// import uParse from '@/components/u-parse/u-parse.vue';
	import store from "@/store";



	export default {
		components: {
			custom_navbar
			// uParse
		},
		data() {
			return {

				navigateTo,
				navigateBack,
				navbar_title: "消息列表",
				statusBarHeight: 20,
				newsList:[],
				curPage: 0,
				total: 0,
				sid:''
			

			};
		},
		computed: {
			rec_url() {
				return this.$store.getters.rec_url;
			}

		},


		mounted() {
			let that = this;
			const info = uni.getSystemInfoSync();
			that.statusBarHeight = info.statusBarHeight + 43;

		},

		onLoad(options) {
			this.sid = options.sid;
			this.getList();

		},


		onShow() {

		},

		onReachBottom() {
			this.loadMore();
		},


		methods: {

			loadMore() {
				
				let isLoad = Math.ceil(this.total / 10) > this.curPage;
				if (isLoad) {
					this.getList();
				}
			},
			// 获取头的高度
			// 获取头的高度
			getNavHeight(e) {
				this.NavHeight_infoHeight += e;
			},
			
			async getList(){
				let params = {
					page: this.curPage + 1,
					limit: 10,
					spot_id:this.sid
				
				};
				let res = await noticeList(params);
				if (res.code == 200) {
					this.curPage = params.page;
				
					this.total = res.data.total;
					let datas = [...this.newsList];
					if (params.page > 1) {
						datas.push(...res.data.data)
					} else {
						datas = res.data.data;
					}
					
					this.newsList = datas;
					
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import './this.scss';
	
	.list-nodata {
		height: 200rpx;
		line-height: 200rpx;
		text-align: center;
		background-color: #fff;
		border-radius: 32rpx;
	}
</style>